home *** CD-ROM | disk | FTP | other *** search
/ Network PC / Network PC.iso / amiga utilities / communication / bbs / termv4.6 / extras / source / gtlayout-source.lha / LT_SetAttributes.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-03-18  |  28.5 KB  |  1,360 lines

  1. /*
  2. **    GadTools layout toolkit
  3. **
  4. **    Copyright © 1993-1996 by Olaf `Olsen' Barthel
  5. **        Freely distributable.
  6. **
  7. **    :ts=4
  8. */
  9.  
  10. #ifndef _GTLAYOUT_GLOBAL_H
  11. #include "gtlayout_global.h"
  12. #endif
  13.  
  14. /*void Dummy(...) {}*/
  15.  
  16. /*#define GT_SetGadgetAttrsA Dummy*/
  17. /*#define GT_SetGadgetAttrs Dummy*/
  18.  
  19. VOID __stdargs
  20. LT_SetAttributes(LayoutHandle *handle,LONG id,...)
  21. {
  22.     va_list VarArgs;
  23.  
  24.     va_start(VarArgs,id);
  25.     LT_SetAttributesA(handle,id,(struct TagItem *)VarArgs);
  26.     va_end(VarArgs);
  27. }
  28.  
  29.  
  30. /*****************************************************************************/
  31.  
  32.  
  33. VOID
  34. LTP_AddAllAndRefreshThisGadget(LayoutHandle *Handle,struct Gadget *Gadget)
  35. {
  36.     AddGList(Handle->Window,Handle->List,(UWORD)-1,(UWORD)-1,NULL);
  37.     RefreshGList(Gadget,Handle->Window,NULL,1);
  38. }
  39.  
  40. VOID
  41. LTP_FixState(LayoutHandle *Handle,BOOL State,struct Gadget *Gadget,UWORD Bit)
  42. {
  43.     if(Gadget)
  44.     {
  45.         LTP_StripGadgets(Handle,Handle->List);
  46.  
  47.         if(State)
  48.             Gadget->Flags |=  Bit;
  49.         else
  50.             Gadget->Flags &= ~Bit;
  51.  
  52.         LTP_AddAllAndRefreshThisGadget(Handle,Gadget);
  53.     }
  54. }
  55.  
  56. BOOL
  57. LTP_NotifyPager(LayoutHandle *Handle,LONG ID,LONG Page)
  58. {
  59.     if(ID != -1)
  60.     {
  61.         LT_SetAttributes(Handle,ID,
  62.             LAGR_ActivePage,Page,
  63.         TAG_DONE);
  64.  
  65.         if(Handle->Failed)
  66.             return(FALSE);
  67.     }
  68.  
  69.     return(TRUE);
  70. }
  71.  
  72.  
  73. /*****************************************************************************/
  74.  
  75.  
  76. /****** gtlayout.library/LT_SetAttributesA ******************************************
  77. *
  78. *   NAME
  79. *    LT_SetAttributesA -- Change object attributes
  80. *
  81. *   SYNOPSIS
  82. *    LT_SetAttributesA(Handle,ID,Tags);
  83. *                        A0   D0  A1
  84. *
  85. *    VOID LT_SetAttributes(LayoutHandle *,LONG,struct TagItem *);
  86. *
  87. *    LT_SetAttributes(Handle,ID,...);
  88. *
  89. *    VOID LT_SetAttributes(LayoutHandle *,LONG,...);
  90. *
  91. *   FUNCTION
  92. *    This routine passes the tag item list it gets directly
  93. *    over to GT_SetGadgetAttrsA(), so any tag items valid for
  94. *    gadtools.library can be used here as well. Some filtering
  95. *    may be done in order to stop objects from getting redrawn
  96. *    if this is not absolutely necessary.
  97. *
  98. *   INPUTS
  99. *    Handle - Pointer to LayoutHandle.
  100. *
  101. *    ID - ID number of the object to change. This is the same value
  102. *        you passed via LA_ID to LT_New() when you created this object.
  103. *
  104. *    Tags - Attributes controlling object states.
  105. *
  106. *
  107. *    All gadtools.library tags are allowed, but not all are supported.
  108. *    In addition to these tags a few additional tag values are
  109. *    supported:
  110. *
  111. *    LAHN_AutoActivate (BOOL) - Set to TRUE if you want the interface
  112. *        to always keep a string gadget active if possible. Hitting
  113. *        the return key will then cause the next following string
  114. *        gadget to get activated, either cycling through all the
  115. *        string gadgets available or stopping at the next string
  116. *        gadget to have the LAST_LastGadget attribute set.
  117. *
  118. *    LAHN_UserData (APTR) - Store user specific data in the
  119. *        LayoutHandle->UserData entry.
  120. *        (requires gtlayout.library v9 or higher)
  121. *
  122. *    LAHN_RawKeyFilter (BOOL) - Discard unprocessed IDCMP_RAWKEY
  123. *        events.
  124. *        Default: TRUE
  125. *        (requires gtlayout.library v13 or higher)
  126. *
  127. *    LAHN_LocaleHook (struct Hook *) - The hook to call when
  128. *        locale string IDs are to be mapped to strings. The
  129. *        hook function is called with the following parameters:
  130. *
  131. *        String = HookFunc(struct Hook *Hook,struct LayoutHandle *Handle,
  132. *          D0                            A0                         A2
  133. *                          LONG ID)
  134. *                               A1
  135. *
  136. *        The function is to look up the string associated with the ID
  137. *        passed in and return the string.
  138. *
  139. *    LAHN_ExitFlush (BOOL) - When the LayoutHandle is finally disposed
  140. *        of with LT_DeleteHandle() all variables maintained by the
  141. *        input handling code will be flushed. For example, if you
  142. *        would use the LA_STRPTR tag for STRING_KIND objects the
  143. *        last string gadget contents would be copied into the buffer
  144. *        pointed to by LA_STRPTR. If you do not want to use this
  145. *        feature, disable it with "LAHN_ExitFlush,FALSE".
  146. *        Default: TRUE
  147. *        (requires gtlayout.library v9 or higher)
  148. *
  149. *    GAUGE_KIND:
  150. *
  151. *        LAGA_Percent (LONG) - Percentage of the gauge to fill.
  152. *
  153. *        LAGA_InfoText (STRPTR) - Text to be printed within the
  154. *            gauge display, such as a percentage number.
  155. *
  156. *    BOX_KIND:
  157. *
  158. *        LABX_Index (LONG) - The number of the line to change, this
  159. *            tag works in conjunction with the LABX_Text tag.
  160. *
  161. *        LABX_Text (STRPTR) - The text to put into the line indicated
  162. *            by the LABX_Index tag.
  163. *            As of v26 the LABX_Index tag may be omitted, the library
  164. *            will then assume the line index will be 0.
  165. *
  166. *        LABX_Lines (STRPTR *) - The text to set for the box contents,
  167. *            terminate the text array with NULL.
  168. *
  169. *    HORIZONTAL_KIND:
  170. *    VERTICAL_KIND:
  171. *
  172. *        LAGR_ActivePage (LONG) - Index number of page to display
  173. *            within the group.
  174. *
  175. *                NOTE: requires that this group was created
  176. *                    with the LAGR_ActivePage attribute set.
  177. *
  178. *    FRACTION_KIND:
  179. *
  180. *        LAFC_Number (FIXED) - Fixed point number to use
  181. *
  182. *        LAFC_Min (FIXED) - Minimum allowed value for this
  183. *            object.
  184. *
  185. *        LAFC_Max (FIXED) - Maximum allowed value for this
  186. *            object.
  187. *
  188. *    INTEGER_KIND:
  189. *
  190. *        LAIN_Min (LONG) - Minimum allowed value for this
  191. *            object.
  192. *
  193. *        LAIN_Max (LONG) - Maximum allowed value for this
  194. *            object.
  195. *
  196. *    PASSWORD_KIND:
  197. *
  198. *        LAPW_String (STRPTR) - Secret text to use
  199. *
  200. *    POPUP_KIND
  201. *
  202. *        LAPU_Labels (STRPTR *) - To block access to the popup
  203. *            menu, for example before you free the current list
  204. *            of labels, you can pass ~0 as the list parameter.
  205. *            (requires gtlayout.library v25 or higher)
  206. *
  207. *    STRING_KIND:
  208. *
  209. *        LAST_CursorPosition (LONG) - Repositions the cursor,
  210. *            pass -1 to move it to the end of the string.
  211. *            (requires gtlayout.library v7 or higher)
  212. *
  213. *    TAPEDECK_KIND:
  214. *
  215. *        LATD_Pressed (BOOL) - TRUE to make this button shown
  216. *            as pressed, FALSE to show it in depressed state.
  217. *
  218. *    BOOPSI_KIND:
  219. *
  220. *        All tags are passed straight through to SetGadgetAttrs(..).
  221. *
  222. *    All objects:
  223. *
  224. *        LA_LabelText (STRPTR) - New gadget label text to use.
  225. *
  226. *        LA_LabelID (LONG) - Locale text ID to use for this object.
  227. *
  228. *   RESULT
  229. *    none
  230. *
  231. *   SEE ALSO
  232. *    gadtools.library/GT_SetGadgetAttrsA()
  233. *    intuition.library/SetGadgetAttrsA
  234. *
  235. ******************************************************************************
  236. *
  237. */
  238.  
  239. VOID LIBENT
  240. LT_SetAttributesA(_REG(a0) LayoutHandle *handle,_REG(d0) LONG id,_REG(a1) struct TagItem *TagList)
  241. {
  242.     if(handle && TagList)
  243.     {
  244.         struct Gadget    *Gadget = NULL;
  245.         struct TagItem    *ThisTag,*ThisList = TagList;
  246.         ObjectNode        *Node = NULL;
  247.  
  248.         while(ThisTag = NextTagItem(&ThisList))
  249.         {
  250.             switch(ThisTag->ti_Tag)
  251.             {
  252.                 case LH_AutoActivate:
  253.  
  254.                     handle->AutoActivate = ThisTag->ti_Data;
  255.                     break;
  256.  
  257.                 case LH_RawKeyFilter:
  258.  
  259.                     handle->RawKeyFilter = ThisTag->ti_Data;
  260.                     break;
  261.  
  262.                 case LH_UserData:
  263.  
  264.                     handle->UserData = (APTR)ThisTag->ti_Data;
  265.                     break;
  266.  
  267.                 case LH_ExitFlush:
  268.  
  269.                     handle->ExitFlush = ThisTag->ti_Data;
  270.                     break;
  271.  
  272.                 case LH_LocaleHook:
  273.  
  274.                     handle->LocaleHook = (struct Hook *)ThisTag->ti_Data;
  275.                     break;
  276.  
  277.                 case LAPR_Gadget:
  278.  
  279.                     Gadget = (struct Gadget *)ThisTag->ti_Data;
  280.                     break;
  281.  
  282.                 case LAPR_Object:
  283.  
  284.                     Node = (ObjectNode *)ThisTag->ti_Data;
  285.                     break;
  286.             }
  287.         }
  288.  
  289.         if(Node)
  290.             Gadget = Node->Host;
  291.         else
  292.         {
  293.             if(Gadget)
  294.             {
  295.                 if(Node = (ObjectNode *)Gadget->UserData)
  296.                 {
  297.                     if(Node->Host != Gadget || Node->PointBack != Node)
  298.                         Node = NULL;
  299.                 }
  300.             }
  301.         }
  302.  
  303.         if(!Gadget)
  304.         {
  305.             if(Gadget = LTP_FindGadget(handle,id))
  306.             {
  307.                 if(Node = (ObjectNode *)Gadget->UserData)
  308.                 {
  309.                     if(Node->Host != Gadget || Node->PointBack != Node)
  310.                         Node = NULL;
  311.                 }
  312.             }
  313.             else
  314.                 Node = LTP_FindNode(handle,id);
  315.         }
  316.  
  317.         if(Node)
  318.         {
  319.             STATIC Tag Filter[] = { GA_Disabled,TAG_DONE };
  320.  
  321.             struct TagItem    *NewTags = NULL;
  322.             ULONG             Exclude = NULL;
  323.  
  324.             switch(Node->Type)
  325.             {
  326. #ifdef DO_PASSWORD_KIND
  327.                 case PASSWORD_KIND:
  328.  
  329.                     if(ThisTag = FindTagItem(GTST_String,TagList))
  330.                     {
  331.                         STRPTR String;
  332.                         LONG Len;
  333.  
  334.                         String = (STRPTR)TagList->ti_Data;
  335.  
  336.                         if(String)
  337.                             Len = strlen(String);
  338.                         else
  339.                         {
  340.                             String = "";
  341.                             Len = 0;
  342.                         }
  343.  
  344.                         Exclude = GTST_String;
  345.  
  346.                         strcpy(Node->Special.String.RealString,String);
  347.  
  348.                         if(Len)
  349.                         {
  350.                             memset(Node->Special.String.Original,'·',Len);
  351.                             Node->Special.String.Original[Len] = 0;
  352.                         }
  353.  
  354.                         GT_SetGadgetAttrs(Gadget,handle->Window,NULL,
  355.                             GTST_String,Node->Special.String.Original,
  356.                         TAG_DONE);
  357.                     }
  358.  
  359.                     break;
  360. #endif
  361. #ifdef DO_BOOPSI_KIND
  362.                 case BOOPSI_KIND:
  363.  
  364.                     if(ThisTag = FindTagItem(GA_Disabled,TagList))
  365.                         Node->Disabled = ThisTag->ti_Data;
  366.  
  367.                     if(Node->Special.BOOPSI.TagCurrent)
  368.                     {
  369.                         if(ThisTag = FindTagItem(Node->Special.BOOPSI.TagCurrent,TagList))
  370.                             Node->Current = ThisTag->ti_Data;
  371.                     }
  372.  
  373.                     if(Node->Host)
  374.                         SetGadgetAttrsA(Node->Host,handle->Window,NULL,TagList);
  375.  
  376.                     return;
  377. #endif    /* DO_BOOPSI_KIND */
  378.                 case STRING_KIND:
  379.  
  380.                     if(ThisTag = FindTagItem(GTST_String,TagList))
  381.                     {
  382.                         Exclude = GTST_String;
  383.  
  384.                         if(Gadget)
  385.                         {
  386.                             GT_SetGadgetAttrs(Gadget,handle->Window,NULL,
  387.                                 GTST_String,ThisTag->ti_Data,
  388.                             TAG_DONE);
  389.                         }
  390.                         else
  391.                         {
  392.                             if(!Node->Special.String.Backup)
  393.                                 Node->Special.String.Backup = (STRPTR)LTP_Alloc(handle,Node->Special.String.MaxChars + 1);
  394.  
  395.                             if(Node->Special.String.Backup)
  396.                             {
  397.                                 if(ThisTag->ti_Data)
  398.                                     strcpy(Node->Special.String.Backup,(STRPTR)ThisTag->ti_Data);
  399.                                 else
  400.                                     Node->Special.String.Backup[0] = 0;
  401.  
  402.                                 Node->Special.String.String = Node->Special.String.Backup;
  403.                             }
  404.                         }
  405.                     }
  406.  
  407.                     if(Gadget)
  408.                     {
  409.                         if(ThisTag = FindTagItem(LAST_CursorPosition,TagList))
  410.                         {
  411.                             struct StringInfo    *StringInfo = Gadget->SpecialInfo;
  412.                             LONG                 Position,Len;
  413.  
  414.                             LTP_StripGadgets(handle,handle->List);
  415.  
  416.                             Position = (LONG)ThisTag->ti_Data;
  417.  
  418.                             Len = strlen(StringInfo->Buffer);
  419.  
  420.                             if(Position == -1)
  421.                                 Position = Len;
  422.                             else
  423.                             {
  424.                                 if(Position < 0)
  425.                                     Position = 0;
  426.                                 else
  427.                                 {
  428.                                     if(Position > Len)
  429.                                         Position = Len;
  430.                                 }
  431.                             }
  432.  
  433.                             StringInfo->BufferPos = Position;
  434.  
  435.                             LTP_AddAllAndRefreshThisGadget(handle,Gadget);
  436.                         }
  437.                     }
  438.  
  439.                     break;
  440.  
  441. #ifdef DO_LEVEL_KIND
  442.                 case LEVEL_KIND:
  443.                 {
  444.                     LevelExtra    *Special    = &Node->Special.Level;
  445.                     BOOL         ChangeIt    = FALSE;
  446.  
  447.                     if(ThisTag = FindTagItem(LAVL_Min,TagList))
  448.                     {
  449.                         Special->Plus = Special->Min = (LONG)ThisTag->ti_Data;
  450.  
  451.                         ChangeIt = TRUE;
  452.                     }
  453.  
  454.                     if(ThisTag = FindTagItem(LAVL_Max,TagList))
  455.                     {
  456.                         Special->Max = (LONG)ThisTag->ti_Data;
  457.  
  458.                         ChangeIt = TRUE;
  459.                     }
  460.  
  461.                     if(ThisTag = FindTagItem(LAVL_Level,TagList))
  462.                     {
  463.                         Special->Level = (LONG)ThisTag->ti_Data;
  464.  
  465.                         LTP_PutStorage(Node);
  466.  
  467.                         ChangeIt = TRUE;
  468.                     }
  469.  
  470.                     if(Special->Max < Special->Min)
  471.                         Special->Max = Special->Min;
  472.  
  473.                     if(Special->Level > Special->Max)
  474.                         Special->Level = Special->Max;
  475.  
  476.                     if(Special->Level < Special->Min)
  477.                         Special->Level = Special->Min;
  478.  
  479.                     if(ChangeIt && Gadget && handle->Window)
  480.                     {
  481.                         LONG Plus = Special->Plus;
  482.  
  483.                         SetAttrs(Special->LevelImage,
  484.                             LVIA_Current,    Special->Level    - Plus,
  485.                             LVIA_Max,    Special->Max        - Plus,
  486.                         TAG_DONE);
  487.  
  488.                         DrawImageState(&handle->RPort,Special->LevelImage,Gadget->LeftEdge,Gadget->TopEdge,IDS_NORMAL,handle->DrawInfo);
  489.  
  490.                         LTP_LevelGadgetDrawLabel(Gadget,FALSE);
  491.                     }
  492.  
  493.                     break;
  494.                 }
  495. #endif    /* DO_LEVEL_KIND */
  496.                 case CHECKBOX_KIND:
  497.  
  498.                     if(ThisTag = FindTagItem(GTCB_Checked,TagList))
  499.                     {
  500.                         if((Node->Current && ThisTag->ti_Data) || (!Node->Current && !ThisTag->ti_Data))
  501.                             Exclude = GTCB_Checked;
  502.                         else
  503.                         {
  504.                             Node->Current = ThisTag->ti_Data;
  505.  
  506.                             LTP_PutStorage(Node);
  507.                         }
  508.                     }
  509.  
  510.                     break;
  511.  
  512. #ifdef DO_TAPEDECK_KIND
  513.                 case TAPEDECK_KIND:
  514.  
  515.                     if(ThisTag = FindTagItem(LATD_Pressed,TagList))
  516.                     {
  517.                         if(Node->Current != ThisTag->ti_Data && Node->Special.TapeDeck.Toggle)
  518.                         {
  519.                             Node->Current = ThisTag->ti_Data;
  520.  
  521.                             LTP_FixState(handle,Node->Current,Gadget,GFLG_SELECTED);
  522.                         }
  523.                     }
  524.  
  525.                     break;
  526. #endif    /* DO_TAPEDECK_KIND */
  527.  
  528. #ifdef DO_GAUGE_KIND
  529.                 case GAUGE_KIND:
  530.                 {
  531.                     LONG Percent         = (LONG)Node->Current;
  532.                     BOOL NeedRefresh    = FALSE;
  533.  
  534.                     if(ThisTag = FindTagItem(LAGA_Percent,TagList))
  535.                     {
  536.                         Percent = (LONG)ThisTag->ti_Data;
  537.  
  538.                         if(Percent < 0)
  539.                             Percent = 0;
  540.                         else
  541.                         {
  542.                             if(Percent > 100)
  543.                                 Percent = 100;
  544.                         }
  545.  
  546.                         if(Percent != (LONG)Node->Current)
  547.                             NeedRefresh = TRUE;
  548.                     }
  549.  
  550.                     if(ThisTag = FindTagItem(LAGA_InfoText,TagList))
  551.                     {
  552.                         STRPTR SomeText = (STRPTR)ThisTag->ti_Data;
  553.  
  554.                         if(Node->Special.Gauge.InfoLength)
  555.                         {
  556.                             LONG Len = strlen(SomeText);
  557.  
  558.                             if(Len > Node->Special.Gauge.InfoLength)
  559.                                 Len = Node->Special.Gauge.InfoLength;
  560.  
  561.                             CopyMem(SomeText,Node->Special.Gauge.InfoText,Len);
  562.  
  563.                             Node->Special.Gauge.InfoText[Len] = 0;
  564.  
  565.                             NeedRefresh = TRUE;
  566.                         }
  567.                     }
  568.  
  569.                     if(NeedRefresh && Gadget)
  570.                         LTP_DrawGauge(handle,Node,Percent,FALSE);
  571.                 }
  572.  
  573.                 return;
  574. #endif
  575.                 case LISTVIEW_KIND:
  576.  
  577.                     if(ThisTag = FindTagItem(GTLV_Labels,TagList))
  578.                     {
  579.                         Node->Special.List.Labels = (struct List *)ThisTag->ti_Data;
  580.  
  581.                         if(ThisTag->ti_Data == (ULONG)~0)
  582.                             Node->Min = Node->Max = -1;
  583.                         else
  584.                         {
  585.                             struct List    *List;
  586.                             LONG         Count = 0;
  587.                             struct Node    *Item;
  588.  
  589.                             if(ThisTag->ti_Data)
  590.                                 List = (struct List *)ThisTag->ti_Data;
  591.                             else
  592.                             {
  593.                                 STATIC Tag Filter[] = { GTLV_Labels,TAG_DONE };
  594.  
  595.                                 LONG Current = (LONG)GetTagData(GTLV_Selected,(ULONG)Node->Current,TagList);
  596.  
  597.                                 if(!NewTags)
  598.                                 {
  599.                                     if(!(NewTags = CloneTagItems(TagList)))
  600.                                         return;
  601.                                 }
  602.  
  603.                                 FilterTagItems(NewTags,Filter,TAGFILTER_NOT);
  604.  
  605.                                 List = (struct List *)<P_EmptyList;
  606.  
  607.                                 GT_SetGadgetAttrs(Gadget,handle->Window,NULL,
  608.                                     GTLV_Labels,    List,
  609.                                     GTLV_Selected,    Current,
  610.                                 TAG_DONE);
  611.  
  612.                                 Node->Special.List.Labels = List;
  613.                             }
  614.  
  615.                             SCANLIST(List,Item)
  616.                             {
  617.                                 Count++;
  618.                             }
  619.  
  620.                             Node->Min = 0;
  621.  
  622.                             if(Count)
  623.                                 Node->Max = Count - 1;
  624.                             else
  625.                                 Node->Max = 0;
  626.                         }
  627.                     }
  628.  
  629.                     if(ThisTag = FindTagItem(GTLV_Selected,TagList))
  630.                     {
  631.                         Node->Current = (LONG)ThisTag->ti_Data;
  632.  
  633.                         if(Gadget)
  634.                         {
  635.                             Exclude = GTLV_Selected;
  636.  
  637.                             GT_SetGadgetAttrs(Gadget,handle->Window,NULL,
  638.                                 GTLV_Selected,        Node->Current,
  639.                                 GTLV_Labels,        Node->Special.List.Labels,
  640.  
  641.                                 (Node->Current < 0) ? TAG_DONE : TAG_IGNORE,0,
  642.  
  643.                                 GTLV_MakeVisible,    Node->Current,
  644.                                 GTLV_Top,            Node->Current,
  645.                             TAG_DONE);
  646.                         }
  647.  
  648.                         LTP_PutStorage(Node);
  649.  
  650.                         if(!LTP_NotifyPager(handle,Node->Special.List.AutoPageID,Node->Current))
  651.                             return;
  652.                     }
  653.  
  654.                     if(ThisTag = FindTagItem(GA_Disabled,TagList))
  655.                     {
  656.                         if(!V39)
  657.                         {
  658.                             if(!NewTags)
  659.                             {
  660.                                 if(!(NewTags = CloneTagItems(TagList)))
  661.                                     return;
  662.                             }
  663.  
  664.                             FilterTagItems(NewTags,Filter,TAGFILTER_NOT);
  665.                         }
  666.                     }
  667.  
  668.                     break;
  669.  
  670.                 case MX_KIND:
  671.  
  672.                     if(ThisTag = FindTagItem(GTMX_Active,TagList))
  673.                     {
  674.                         if(Node->Current == ThisTag->ti_Data)
  675.                             Exclude = GTMX_Active;
  676.                         else
  677.                         {
  678.                             Node->Current = ThisTag->ti_Data;
  679.  
  680.                             LTP_PutStorage(Node);
  681.  
  682.                             if(!LTP_NotifyPager(handle,Node->Special.Radio.AutoPageID,Node->Current))
  683.                                 return;
  684.                         }
  685.                     }
  686.  
  687.                     if(!V39)
  688.                     {
  689.                         if(FindTagItem(GA_Disabled,TagList))
  690.                         {
  691.                             if(!(NewTags = CloneTagItems(TagList)))
  692.                                 return;
  693.                             else
  694.                                 FilterTagItems(NewTags,Filter,TAGFILTER_NOT);
  695.                         }
  696.                     }
  697.  
  698.                     break;
  699.  
  700.                 case CYCLE_KIND:
  701.  
  702.                     if(ThisTag = FindTagItem(GTCY_Active,TagList))
  703.                     {
  704.                         if(Node->Current == ThisTag->ti_Data)
  705.                             Exclude = GTCY_Active;
  706.                         else
  707.                         {
  708.                             Node->Current = ThisTag->ti_Data;
  709.  
  710.                             LTP_PutStorage(Node);
  711.  
  712.                             if(!LTP_NotifyPager(handle,Node->Special.Cycle.AutoPageID,Node->Current))
  713.                                 return;
  714.                         }
  715.                     }
  716.  
  717.                     if(ThisTag = FindTagItem(GTCY_Labels,TagList))
  718.                     {
  719.                         STRPTR    *Strings;
  720.                         LONG     Count = 0;
  721.  
  722.                         if(Strings = (STRPTR *)ThisTag->ti_Data)
  723.                         {
  724.                             while(Strings[Count])
  725.                                 Count++;
  726.                         }
  727.  
  728.                         if(Count)
  729.                             Node->Max = Count - 1;
  730.                         else
  731.                             Node->Max = 0;
  732.                     }
  733.  
  734.                     break;
  735. #if defined(DO_POPUP_KIND) && defined(DO_BOOPSI_KIND)
  736.                 case POPUP_KIND:
  737.                 {
  738.                     BOOL NewCurrent = FALSE,NewLabels = FALSE;
  739.  
  740.                     if(ThisTag = FindTagItem(GA_Disabled,TagList))
  741.                         Node->Disabled = ThisTag->ti_Data;
  742.  
  743.                     if(ThisTag = FindTagItem(LAPU_Labels,TagList))
  744.                     {
  745.                         STRPTR    *Strings;
  746.                         LONG     Count = 0;
  747.  
  748.                         if(Strings = (STRPTR *)ThisTag->ti_Data)
  749.                         {
  750.                             while(Strings[Count])
  751.                                 Count++;
  752.                         }
  753.  
  754.                         if(Count)
  755.                             Node->Max = Count - 1;
  756.                         else
  757.                             Node->Max = 0;
  758.  
  759.                         Node->Special.Popup.Choices = (STRPTR *)ThisTag->ti_Data;
  760.  
  761.                         DB(kprintf("max: %ld\n",Node->Max));
  762.  
  763.                         NewLabels = TRUE;
  764.                     }
  765.  
  766.                     if(ThisTag = FindTagItem(LAPU_Active,TagList))
  767.                     {
  768.                         DB(kprintf("current: %ld tag: %ld\n",Node->Current,ThisTag->ti_Data));
  769.  
  770.                         if(Node->Current != ThisTag->ti_Data)
  771.                         {
  772.                             Node->Current = ThisTag->ti_Data;
  773.  
  774.                             LTP_PutStorage(Node);
  775.  
  776.                             if(!LTP_NotifyPager(handle,Node->Special.Popup.AutoPageID,Node->Current))
  777.                                 return;
  778.  
  779.                             NewCurrent = TRUE;
  780.                         }
  781.                     }
  782.  
  783.                     if(Node->Host)
  784.                     {
  785.                         SetGadgetAttrs(Node->Host,handle->Window,NULL,
  786.                             NewCurrent ? PIA_Active : TAG_IGNORE,    Node->Current,
  787.                             NewLabels ? PIA_Labels : TAG_IGNORE,    Node->Special.Popup.Choices,
  788.                         TAG_MORE,TagList);
  789.                     }
  790.  
  791.                     return;
  792.                 }
  793. #endif
  794.  
  795. #if defined(DO_TAB_KIND) && defined(DO_BOOPSI_KIND)
  796.                 case TAB_KIND:
  797.                 {
  798.                     if(ThisTag = FindTagItem(GA_Disabled,TagList))
  799.                         Node->Disabled = ThisTag->ti_Data;
  800.  
  801.                     if(ThisTag = FindTagItem(LATB_Active,TagList))
  802.                     {
  803.                         DB(kprintf("current: %ld tag: %ld\n",Node->Current,ThisTag->ti_Data));
  804.  
  805.                         if(Node->Current != ThisTag->ti_Data)
  806.                         {
  807.                             Node->Current = ThisTag->ti_Data;
  808.  
  809.                             LTP_PutStorage(Node);
  810.  
  811.                             if(!LTP_NotifyPager(handle,Node->Special.Tab.AutoPageID,Node->Current))
  812.                                 return;
  813.                             else
  814.                             {
  815.                                 if(Node->Host)
  816.                                 {
  817.                                     SetGadgetAttrs(Node->Host,handle->Window,NULL,
  818.                                         TIA_Index,Node->Current,
  819.                                     TAG_MORE,TagList);
  820.                                 }
  821.                             }
  822.                         }
  823.                     }
  824.  
  825.                     return;
  826.                 }
  827. #endif
  828.                 case PALETTE_KIND:
  829.  
  830.                     if(ThisTag = FindTagItem(GTPA_Color,TagList))
  831.                     {
  832.                         if(Node->Current == ThisTag->ti_Data)
  833.                             Exclude = GTPA_Color;
  834.                         else
  835.                         {
  836.                             Node->Current = ThisTag->ti_Data;
  837.  
  838.                             LTP_PutStorage(Node);
  839.  
  840.                             if(Node->Special.Palette.UsePicker)
  841.                             {
  842.                                 if(Gadget)
  843.                                     LTP_DrawPalette(handle,Node);
  844.  
  845.                                 return;
  846.                             }
  847.                         }
  848.                     }
  849.  
  850.                     break;
  851.  
  852.                 case INTEGER_KIND:
  853.  
  854.                     if(ThisTag = FindTagItem(GTIN_Number,TagList))
  855.                     {
  856.                         LONG num = ThisTag->ti_Data;
  857.  
  858.                         if(num < Node->Min)
  859.                             num = Node->Min;
  860.                         else
  861.                         {
  862.                             if(num > Node->Max)
  863.                                 num = Node->Max;
  864.                         }
  865.  
  866.                         if(Gadget)
  867.                         {
  868. #ifdef DO_HEXHOOK
  869.                             if(!Node->Special.Integer.EditHook || Node->Special.Integer.CustomHook)
  870.                             {
  871.                                 UBYTE                 buffer[20];
  872.                                 struct StringInfo    *stringInfo;
  873.  
  874.                                 SPrintf(buffer,"%ld",num);
  875.  
  876.                                 Exclude = GTIN_Number;
  877.  
  878.                                 GT_SetGadgetAttrs(Gadget,handle->Window,NULL,
  879.                                     GTST_String,    buffer,
  880.                                     GTIN_Number,    num,
  881.                                 TAG_DONE);
  882.  
  883.                                 stringInfo = (struct StringInfo *)Gadget->SpecialInfo;
  884.  
  885.                                 stringInfo->LongInt = num;
  886.                             }
  887.                             else
  888.                             {
  889.                                 UBYTE                 buffer[40];
  890.                                 struct StringInfo    *stringInfo;
  891.                                 STRPTR                 Index;
  892.                                 LONG                 Value,Number = num,
  893.                                                      Scale,Sign;
  894.  
  895.                                 stringInfo = (struct StringInfo *)Gadget->SpecialInfo;
  896.  
  897.                                 Index = stringInfo->Buffer;
  898.  
  899.                                 while(*Index && *Index == ' ')
  900.                                     Index++;
  901.  
  902.                                 switch(Index[0])
  903.                                 {
  904.                                     case '$':
  905.  
  906.                                         SPrintf(buffer,"$%lx",num);
  907.                                         break;
  908.  
  909.                                     case '&':
  910.  
  911.                                         if(Number < 0)
  912.                                         {
  913.                                             Sign = -1;
  914.                                             Number = -Number;
  915.                                         }
  916.                                         else
  917.                                             Sign = 1;
  918.  
  919.                                         for(Value = 0, Scale = 1 ; Number ; Number /= 8, Scale *= 10)
  920.                                             Value += (Number & 7) * Scale;
  921.  
  922.                                         SPrintf(buffer,"&%ld",(LONG)(Sign * Value));
  923.                                         break;
  924.  
  925.                                     case '%':
  926.  
  927.                                         if(Number < 0)
  928.                                         {
  929.                                             Sign = -1;
  930.                                             Number = -Number;
  931.                                         }
  932.                                         else
  933.                                             Sign = 1;
  934.  
  935.                                         for(Value = 0, Scale = 1 ; Number ; Number /= 2, Scale *= 10)
  936.                                             Value += (Number & 1) * Scale;
  937.  
  938.                                         SPrintf(buffer,"%%%ld",(LONG)(Sign * Value));
  939.                                         break;
  940.  
  941.                                     case '0':
  942.  
  943.                                         if(Index[1] == 'x')
  944.                                         {
  945.                                             SPrintf(buffer,"0x%lx",num);
  946.                                             break;
  947.                                         }
  948.  
  949.                                         // Fall through to...
  950.  
  951.                                     default:
  952.  
  953.                                         SPrintf(buffer,"%ld",num);
  954.                                         break;
  955.                                 }
  956.  
  957.                                 Exclude = GTIN_Number;
  958.  
  959.                                 GT_SetGadgetAttrs(Gadget,handle->Window,NULL,
  960.                                     GTST_String,buffer,
  961.                                 TAG_DONE);
  962.  
  963.                                 stringInfo->LongInt = num;
  964.                             }
  965. #else
  966.                             GT_SetGadgetAttrs(Gadget,handle->Window,NULL,
  967.                                 GTIN_Number,num,
  968.                             TAG_DONE);
  969. #endif
  970.                         }
  971.  
  972.                         Node->Special.Integer.Number = num;
  973.  
  974.                         LTP_PutStorage(Node);
  975.                     }
  976.  
  977.                     break;
  978.  
  979.                 case NUMBER_KIND:
  980.  
  981.                     if(ThisTag = FindTagItem(GTNM_Number,TagList))
  982.                         Node->Special.Number.Number = ThisTag->ti_Data;
  983.  
  984.                     break;
  985.  
  986.                 case SLIDER_KIND:
  987.  
  988.                     if(ThisTag = FindTagItem(GTSL_Level,TagList))
  989.                     {
  990.                         if(Node->Current == ThisTag->ti_Data)
  991.                             Exclude = GTSL_Level;
  992.                         else
  993.                         {
  994.                             Node->Current = ThisTag->ti_Data;
  995.  
  996.                             LTP_PutStorage(Node);
  997.                         }
  998.                     }
  999.  
  1000.                     if(ThisTag = FindTagItem(GTSL_Min,TagList))
  1001.                     {
  1002.                         Node->Min = ThisTag->ti_Data;
  1003.  
  1004.                         if(Node->Current < Node->Min)
  1005.                         {
  1006.                             Node->Current = Node->Min;
  1007.  
  1008.                             LTP_PutStorage(Node);
  1009.                         }
  1010.                     }
  1011.  
  1012.                     if(ThisTag = FindTagItem(GTSL_Max,TagList))
  1013.                     {
  1014.                         Node->Max = ThisTag->ti_Data;
  1015.  
  1016.                         if(Node->Current > Node->Max)
  1017.                         {
  1018.                             Node->Current = Node->Max;
  1019.  
  1020.                             LTP_PutStorage(Node);
  1021.                         }
  1022.                     }
  1023.  
  1024.                     break;
  1025.  
  1026.                 case SCROLLER_KIND:
  1027.  
  1028.                     if(ThisTag = FindTagItem(GTSC_Top,TagList))
  1029.                     {
  1030.                         if(Node->Current == ThisTag->ti_Data)
  1031.                             Exclude = GTSC_Top;
  1032.                         else
  1033.                         {
  1034.                             Node->Current = ThisTag->ti_Data;
  1035.  
  1036.                             LTP_PutStorage(Node);
  1037.                         }
  1038.                     }
  1039.  
  1040.                     if(ThisTag = FindTagItem(GTSC_Total,TagList))
  1041.                     {
  1042.                         Node->Max = ThisTag->ti_Data;
  1043.  
  1044.                         if(Node->Current > Node->Max)
  1045.                         {
  1046.                             Node->Current = Node->Max;
  1047.  
  1048.                             LTP_PutStorage(Node);
  1049.                         }
  1050.                     }
  1051.  
  1052.                     if(ThisTag = FindTagItem(GTSC_Visible,TagList))
  1053.                         Node->Special.Scroller.Visible = ThisTag->ti_Data;
  1054.  
  1055.                     break;
  1056.  
  1057.                 case BOX_KIND:
  1058.                 {
  1059.                     BOOL Visible = Node->Special.Box.Parent->Special.Group.Visible;
  1060.  
  1061.                     if(ThisTag = FindTagItem(LABX_Text,TagList))
  1062.                     {
  1063.                         STRPTR    Text = (STRPTR)ThisTag->ti_Data;
  1064.                         LONG    Index;
  1065.  
  1066.                         Index = (LONG)GetTagData(LABX_Index,0,TagList);
  1067.  
  1068.                         if(Index >= 0 && Index < Node->Lines)
  1069.                         {
  1070.                             if(Node->Special.Box.ReserveSpace)
  1071.                             {
  1072.                                 LONG Len = strlen(Text);
  1073.  
  1074.                                 if(Len > Node->Special.Box.MaxSize)
  1075.                                     Len = Node->Special.Box.MaxSize;
  1076.  
  1077.                                 CopyMem(Text,Node->Special.Box.Lines[Index],Len);
  1078.  
  1079.                                 Node->Special.Box.Lines[Index][Len] = 0;
  1080.                             }
  1081.                             else
  1082.                                 Node->Special.Box.Lines[Index] = Text;
  1083.                         }
  1084.  
  1085.                         if(Visible)
  1086.                             LTP_PrintBoxLine(handle,Node,Index);
  1087.                     }
  1088.  
  1089.                     if(ThisTag = FindTagItem(LABX_Lines,TagList))
  1090.                     {
  1091.                         STRPTR    *Lines = (STRPTR *)ThisTag->ti_Data;
  1092.                         LONG     i;
  1093.  
  1094.                         if(Node->Special.Box.ReserveSpace)
  1095.                         {
  1096.                             LONG Len;
  1097.  
  1098.                             for(i = 0 ; i < Node->Lines ; i++)
  1099.                             {
  1100.                                 if(Lines[i])
  1101.                                 {
  1102.                                     Len = strlen(Lines[i]);
  1103.  
  1104.                                     if(Len > Node->Special.Box.MaxSize)
  1105.                                         Len = Node->Special.Box.MaxSize;
  1106.  
  1107.                                     CopyMem(Lines[i],Node->Special.Box.Lines[i],Len);
  1108.  
  1109.                                     Node->Special.Box.Lines[i][Len] = 0;
  1110.  
  1111.                                     if(Visible)
  1112.                                         LTP_PrintBoxLine(handle,Node,i);
  1113.                                 }
  1114.                                 else
  1115.                                     break;
  1116.                             }
  1117.                         }
  1118.                         else
  1119.                         {
  1120.                             for(i = 0 ; i < Node->Lines ; i++)
  1121.                             {
  1122.                                 if(Lines[i])
  1123.                                 {
  1124.                                     Node->Special.Box.Lines[i] = Lines[i];
  1125.  
  1126.                                     if(Visible)
  1127.                                         LTP_PrintBoxLine(handle,Node,i);
  1128.                                 }
  1129.                                 else
  1130.                                     break;
  1131.                             }
  1132.                         }
  1133.                     }
  1134.  
  1135.                     break;
  1136.                 }
  1137.  
  1138.                 case TEXT_KIND:
  1139.  
  1140.                     if(ThisTag = FindTagItem(GTTX_Text,TagList))
  1141.                     {
  1142.                         STRPTR text = (STRPTR)ThisTag->ti_Data;
  1143.  
  1144.                         if(!text)
  1145.                             text = "";
  1146.  
  1147.                         if(Node->Special.Text.CopyText)
  1148.                         {
  1149.                             LONG len;
  1150.  
  1151.                             if(Node->Special.Text.Text)
  1152.                                 len = strlen(Node->Special.Text.Text) + 1;
  1153.                             else
  1154.                                 len = 0;
  1155.  
  1156.                             if(len)
  1157.                                 LTP_Free(handle,Node->Special.Text.Text,len);
  1158.  
  1159.                             len = strlen(text);
  1160.  
  1161.                             if(Node->Special.Text.Text = LTP_Alloc(handle,len + 1))
  1162.                                 strcpy(Node->Special.Text.Text,text);
  1163.                         }
  1164.                         else
  1165.                             Node->Special.Text.Text = text;
  1166.                     }
  1167.  
  1168.                     if(ThisTag = FindTagItem(GTTX_FrontPen,TagList))
  1169.                         Node->Special.Text.FrontPen = (WORD)ThisTag->ti_Data;
  1170.  
  1171.                     if(ThisTag = FindTagItem(GTTX_BackPen,TagList))
  1172.                         Node->Special.Text.BackPen = (WORD)ThisTag->ti_Data;
  1173.  
  1174.                     break;
  1175.  
  1176.                 case GROUP_KIND:
  1177.  
  1178.                     if(Node->Special.Group.Paging)
  1179.                     {
  1180.                         if(ThisTag = FindTagItem(LAGR_ActivePage,TagList))
  1181.                         {
  1182.                             ObjectNode *node;
  1183.  
  1184.                             node = Node;
  1185.  
  1186.                             if(node->Type == GROUP_KIND)
  1187.                             {
  1188.                                 if(node->Special.Group.ActivePage != ThisTag->ti_Data)
  1189.                                 {
  1190.                                     LONG    Left    = node->Left,
  1191.                                             Top        = node->Top,
  1192.                                             Width    = node->Width,
  1193.                                             Height    = node->Height;
  1194.  
  1195.                                     if(node->Label || node->Special.Group.Frame)
  1196.                                     {
  1197.                                         Left    += 4 + handle->GlyphWidth;
  1198.                                         Width    -= 2 * (4 + handle->GlyphWidth);
  1199.  
  1200.                                         if(node->Label)
  1201.                                         {
  1202.                                             Top        += handle->GlyphHeight;
  1203.                                             Height    -= handle->GlyphHeight + 3;
  1204.                                         }
  1205.                                         else
  1206.                                         {
  1207.                                             Top        += 2;
  1208.                                             Height    -= 5;
  1209.                                         }
  1210.                                     }
  1211.  
  1212.                                     node->Special.Group.ActivePage = ThisTag->ti_Data;
  1213.  
  1214.                                     LT_LockWindow(handle->Window);
  1215.  
  1216.                                     LTP_EraseBox(&handle->RPort,Left,Top,Width,Height);
  1217.  
  1218.                                     LT_RebuildTagList(handle,FALSE,NULL);
  1219.  
  1220.                                     LT_UnlockWindow(handle->Window);
  1221.                                 }
  1222.                             }
  1223.                         }
  1224.                     }
  1225.  
  1226.                     break;
  1227.             }
  1228.  
  1229.             if(ThisTag = FindTagItem(LA_LabelText,TagList))
  1230.                 Node->Label = (STRPTR)ThisTag->ti_Data;
  1231.  
  1232.             if(ThisTag = FindTagItem(LA_LabelID,TagList))
  1233.             {
  1234.                 if(handle->LocaleHook)
  1235.                     Node->Label = (STRPTR)CallHookPkt(handle->LocaleHook,handle,(APTR)ThisTag->ti_Data);
  1236.             }
  1237.  
  1238.             if(ThisTag = FindTagItem(GA_Disabled,TagList))
  1239.             {
  1240.                 if((Node->Disabled && ThisTag->ti_Data) || (!Node->Disabled && !ThisTag->ti_Data))
  1241.                 {
  1242.                     if(!NewTags)
  1243.                         NewTags = CloneTagItems(TagList);
  1244.  
  1245.                     if(NewTags)
  1246.                         FilterTagItems(NewTags,Filter,TAGFILTER_NOT);
  1247.                 }
  1248.                 else
  1249.                 {
  1250.                     Node->Disabled = ThisTag->ti_Data;
  1251.  
  1252.                     if(Gadget)
  1253.                     {
  1254.                         struct Gadget *gad;
  1255.  
  1256.                         switch(Node->Type)
  1257.                         {
  1258. #ifdef DO_LEVEL_KIND
  1259.                             case LEVEL_KIND:
  1260.  
  1261.                                 gad = Gadget;
  1262.                                 break;
  1263. #endif    /* DO_LEVEL_KIND */
  1264.                             case TEXT_KIND:
  1265.  
  1266.                                 gad = Node->Special.Text.Picker;
  1267.                                 break;
  1268.  
  1269.                             case STRING_KIND:
  1270.  
  1271.                                 gad = Node->Special.String.Picker;
  1272.                                 break;
  1273.  
  1274.                             case INTEGER_KIND:
  1275.  
  1276.                                 LTP_FixState(handle,Node->Disabled,Node->Special.Integer.LeftIncrementer,GFLG_DISABLED);
  1277.  
  1278.                                 gad = Node->Special.Integer.RightIncrementer;
  1279.                                 break;
  1280.  
  1281.                             case TAPEDECK_KIND:
  1282.  
  1283.                                 gad = Node->Host;
  1284.  
  1285.                                 Gadget = NULL;
  1286.  
  1287.                                 break;
  1288.  
  1289.                             case PALETTE_KIND:
  1290.  
  1291.                                 gad = Node->Special.Palette.Picker;
  1292.                                 break;
  1293.  
  1294.                             case BUTTON_KIND:
  1295.  
  1296.                                 if(Node->Special.Button.ButtonImage)
  1297.                                 {
  1298.                                     gad = Node->Host;
  1299.  
  1300.                                     Gadget = NULL;
  1301.  
  1302.                                     break;
  1303.                                 }
  1304.  
  1305.                                 // FALLS THROUGH TO
  1306.  
  1307.                             default:
  1308.  
  1309.                                 gad = NULL;
  1310.                                 break;
  1311.                         }
  1312.  
  1313.                         LTP_FixState(handle,Node->Disabled,gad,GFLG_DISABLED);
  1314.                     }
  1315.                 }
  1316.             }
  1317.  
  1318.             if(Exclude)
  1319.             {
  1320.                 ULONG Filter[2];
  1321.  
  1322.                 Filter[0] = Exclude;
  1323.                 Filter[1] = TAG_DONE;
  1324.  
  1325.                 if(!NewTags)
  1326.                     NewTags = CloneTagItems(TagList);
  1327.  
  1328.                 if(NewTags)
  1329.                     FilterTagItems(NewTags,Filter,TAGFILTER_NOT);
  1330.             }
  1331.  
  1332.             if(Gadget)
  1333.             {
  1334.                 struct TagItem *tags = TagList;
  1335.  
  1336.                 if(NewTags)
  1337.                     tags = NewTags;
  1338.  
  1339.                 if(!V39 && Node->Disabled && Node->Type == SLIDER_KIND)
  1340.                 {
  1341.                     GT_SetGadgetAttrs(Gadget,handle->Window,NULL,
  1342.                         GA_Disabled,    FALSE,
  1343.                     TAG_MORE,tags);
  1344.  
  1345.                     GT_SetGadgetAttrs(Gadget,handle->Window,NULL,
  1346.                         GA_Disabled,    TRUE,
  1347.                     TAG_DONE);
  1348.                 }
  1349.                 else
  1350.                     GT_SetGadgetAttrsA(Gadget,handle->Window,NULL,tags);
  1351.             }
  1352.  
  1353.             if(Node->Type == STRING_KIND || Node->Type == FRACTION_KIND || Node->Type == PASSWORD_KIND)
  1354.                 LTP_PutStorage(Node);
  1355.  
  1356.             FreeTagItems(NewTags);
  1357.         }
  1358.     }
  1359. }
  1360.